﻿<link rel="stylesheet" type="text/css" href="/public/css/menu/pro_dropdown_2.css" />
<script src="/public/js/menu/stuHover.js" type="text/javascript"></script>
<script src="/public/js/menu/jquery-1.4.2.min.js" type="text/javascript"></script>	
<link rel="stylesheet" type="text/css" href="/public/css/standard/column.css" />
<div class="rootCol">
	<?php echo $this->action('menu','user','LuyenUser');
		Zend_Session::start();	
		$defaultNamespace = new Zend_Session_Namespace('Default');
	?>
	
	<span class="preload1"></span>
	<span class="preload2"></span>
	
	<img border="0" src="/public/img/menu/frog.jpg" alt="Pulpit rock"/>
	<embed height="110" width="400" wmode="transparent" type="application/x-shockwave-flash" src="/public/flash/topbanner.swf">
	<p class="menu_home">
		<a href="http://shoppingcartcnpm.orgfree.com/index.php"><span class="menu_item"> TRANG CHỦ</span></a>
		<a href="<?if($defaultNamespace->user){?>http://shoppingcartcnpm.orgfree.com/index.php/LuyenUser/user/accountinfo<?}else{?>http://shoppingcartcnpm.orgfree.com/index.php/LuyenUser/user/login<?}?>"><span class="menu_item"> TÀI KHOẢN</span></a>
		<a href="<?if($defaultNamespace->user){?>http://shoppingcartcnpm.orgfree.com/index.php/LuyenUser/order/checkout<?}else{?>http://shoppingcartcnpm.orgfree.com/index.php/LuyenUser/user/login<?}?>"><span class="menu_item"> THANH TOÁN</span></a>
		<a href=""><span class="menu_item">ĐẤU GIÁ </span></a>
		<a href=""><span class="menu_item"> GIỚI THIỆU</span></a>
	</p>

	<ul id="nav">
		<?php createTree($this->category,0); ?>
	</ul>
</div>

<?php 

		function createTree($array, $currentParent, $currLevel = 0, $prevLevel = -1) {
				
			foreach ($array as $category) 
			{			
				if ($currentParent == $category['cat_parentID']) 
				{						
					if($currentParent ==0) echo "<li class='top'>".
					"<a class = 'top_link' href='http://shoppingcartcnpm.orgfree.com/index.php/index/viewbycategory?cat_id=".$category['cat_id']."'><span>".$category['cat_ten']."</span></a>";
					else
					{
						if ($currLevel > $prevLevel)
						{ 
							if($currLevel ==1)
							{
								echo " <ul class='sub'> \n";
							}else{
								echo "<ul> \n";
							}		
						}
						
						if ($currLevel == $prevLevel) echo " </li> \n";
						//echo '<li><a href="'.$category['cat_id'].'" >'.$category['cat_ten'].'</a>';
						$modelCategory = new Model_Category();
						$arrayCategory = $modelCategory->getChildCategory($category['cat_id']);
						
						if(count($arrayCategory)>0){
							echo '<li><a href="http://shoppingcartcnpm.orgfree.com/index.php/index/viewbycategory?cat_id='.$category['cat_id'].'" class="fly" >'.$category['cat_ten'].'</a>';
						}
						else{
							echo '<li><a href="http://shoppingcartcnpm.orgfree.com/index.php/index/viewbycategory?cat_id='.$category['cat_id'].'" >'.$category['cat_ten'].'</a>';
						}
					}			
					if ($currLevel > $prevLevel) { $prevLevel = $currLevel; }
					
					$currLevel++; 

					createTree ($array, $category['cat_id'], $currLevel, $prevLevel);
					
					$currLevel--;	 		 	

				}	

			}
			
			if ($currLevel == $prevLevel) echo "\n </li> \n </ul> \n";

		}	
			
?>